<?php
namespace app\common\model;
use think\Model;

class ArticleModel extends Model{
    protected  $name = 'article';
    protected  $pk   = 'article_id';
    // 设置json类型字段
    protected $json = ['detail'];
    // 设置JSON数据返回数组
    protected $jsonAssoc = true;

    public static function onBeforeInsert($model)
    {
        $model->set("create_ip", request()->ip());
    }
    public function category()
    {
        return $this->belongsTo(ArticleCategoryModel::class,'category_id')->bind(['category_name']);
    }
}